using Godot;
using System;

public partial class Pet : Node
{
	public bool dragging;
	// Called when the node enters the scene tree for the first time.
	public override void _Ready()
	{
	}

	// Called every frame. 'delta' is the elapsed time since the previous frame.
	public override void _Process(double delta)
	{
	}

	public override void _Input(InputEvent @event)
	{
		// Mouse in viewport coordinates.
		if (@event is InputEventMouseButton)
		{
			if((@event as InputEventMouseButton).ButtonIndex == MouseButton.Right && (@event as InputEventMouseButton).Pressed)
			{
				dragging = true;
				//GD.Print("开始拖拽");
			}
			else
			{
				dragging = false;
			}
			//GD.Print(dragging);
		}
		if(@event is InputEventMouseMotion)
		{
			if(dragging)
			{
				var wind = GetViewport().GetWindow();
				Vector2I relative = (Vector2I)(@event as InputEventMouseMotion).Relative;
				//GD.Print(relative);
				wind.Position += relative;
				//GD.Print(wind.Position);
			}
			//GD.Print(dragging);
		}
	}
	
	
}
